/**
 *******************************************************************************
 * 
 * <br>(c) Copyright 2012 重庆迅合科技有限公司 
 *
 * <br>文 件  名：DataDictionaryAct.java
 * <br>系统名称：cms
 * <br><br>模块名称：(请更改成该模块名称)
 * <br>创 建  人：彭粟
 * <br>创建日期：Sep 9, 2013 9:47:07 PM
 * <br>修 改 人：(修改了该文件，请填上修改人的名字)
 * <br>修改日期：(请填上修改该文件时的日期)
 * <br>版     本： V1.0.0
 *******************************************************************************  
 */
package com.mvc.cms.action.admin.assist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.mvc.cms.entity.assist.DataDictionary;
import com.mvc.cms.manager.assist.CmsHouseDataMng;
import com.mvc.cms.manager.assist.DataDictionaryMng;
import com.mvc.common.page.SimplePage;

/** DataDictionaryAct概要说明：
 * <br>@author 彭粟
 */
@Controller
public class DataDictionaryAct {
//	private DataDictionary dd;
	private String name;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@RequestMapping(value="/data_dictionary/data_toadd.do",method = RequestMethod.GET)
	public String toAdd(){
				
		System.out.println("看看进来了没有===");
		
		return "config/config_add";
	}
	
	
	
	@RequestMapping(value="/data_dictionary/data_addData.do",method = RequestMethod.POST)
	public String addData(String name,String isUse,String type){
		DataDictionary dic=new DataDictionary() ;
		dic.setName(name);
		dic.setIsUse(Integer.valueOf(isUse));
		dic.setType(Integer.valueOf(type));

		dataDictionaryMng.save(dic);
		return "redirect:data_list.do";
	}
	
	
	/**
	 * updateData方法慨述:修改
	 * <br>
	 */
	@RequestMapping(value="/data_dictionary/data_updateData.do",method = RequestMethod.POST)
	public String updateData(String id,String name,String isUse,String type){
		DataDictionary dic=new DataDictionary() ;
		dic.setId(Integer.valueOf(id));
		dic.setName(name);
		dic.setIsUse(Integer.valueOf(isUse));
		dic.setType(Integer.valueOf(type));

		dataDictionaryMng.save(dic);
		return "redirect:data_list.do";
	}
	/**
	 跳转至修改
	 */
	@RequestMapping(value="/data_dictionary/data_toupdateData.do",method = RequestMethod.GET)
	public String updateData(String id,ModelMap model){
		
		model.put("data",this.dataDictionaryMng.getInfoById(Integer.valueOf(id)));
		return "config/config_update";
	}
	/**
	 * 方法慨述:删除
	 * <br>
	 */
	@RequestMapping(value="/data_dictionary/data_delete.do",method = RequestMethod.GET)
	public String deleteData(String ids[]){
		for(int i=0;i<ids.length;i++){
			DataDictionary dic=dataDictionaryMng.getInfoById(Integer.valueOf(ids[i]));
			
			dataDictionaryMng.delte(dic);
			
		}
		
		return "redirect:data_list.do";
	}
	
	/**
	 * updateData方法慨述:根据id获得对象
	 * <br>
	 */
	@RequestMapping(value="/data_dictionary/data_get.do",method = RequestMethod.POST)
	public String getOneData(String id,String name,String isUse,String type){
		DataDictionary dic=new DataDictionary() ;
		dic.setId(Integer.valueOf(id));
		dic.setName(name);
		dic.setIsUse(Integer.valueOf(isUse));
		dic.setType(Integer.valueOf(type));

		dataDictionaryMng.save(dic);
		return "config/config_update";
	}
	
	
	/**
	 * updateData方法慨述:根据id获得对象
	 * <br>
	 */
	@RequestMapping(value="/data_dictionary/data_list.do",method = RequestMethod.GET)
	public String getDataList( ModelMap model,String type,String isUse,Integer page){
		
		System.out.println("哈哈==========我要开始展示数据啦-------"+page);
		
		model.addAttribute("pagination",dataDictionaryMng.getPage(type,isUse,SimplePage.cpn(page)));
		return "config/config_list";
	}
	
	
	@Autowired
	private DataDictionaryMng dataDictionaryMng;
	public void setDataDictionaryMng(DataDictionaryMng dataDictionaryMng) {
		this.dataDictionaryMng = dataDictionaryMng;
	}
	
	
	
}
